
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="xms">
    <meta name="author" content="xms">
    <link rel="icon" href="/content/favicon.ico">

    <title>自定义 - 实体 - 关系 - 配置关系</title>

    <!-- Bootstrap core CSS -->
    <link href="/content/css/bootstrap3.3.5/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/content/css/dashboard.css" rel="stylesheet">
    <link href="/content/css/font-awesome.min.css" rel="stylesheet">
    <link href="/content/customize/css/common.css" rel="stylesheet">
    <link href="/content/js/jquery-toast/jquery.toast.min.css" rel="stylesheet">
    <link id="themeLink" href="/content/css/theme/default.css" rel="stylesheet" />
    <!-- Bootstrap core JavaScript ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/content/js/jquery.min.js"></script>
    <script src="/content/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="/content/js/ie10-viewport-bug-workaround.js"></script>
    <script src="/content/js/jquery.bootstrap.min.js"></script>
    <script src="/content/js/json2.js"></script>
    <script src="/content/js/xms.utility.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.core.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.widget.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.mouse.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.draggable.js"></script>
    <script src="/content/js/jquery-toast/jquery.toast.min.js"></script>
    <script src="/content/js/xms.jquery.js"></script>
    <script src="/content/js/xms.web.js"></script>
    <script src="/content/js/xms.metadata.js"></script>
    <script src="/content/js/md5.js" type="text/javascript"></script>
    <script src="/content/js/commonlabels.js"></script>
    <script src="/content/js/common/pagecontext.js"></script>
    <script src="/api/user/usercontext"></script>
    <script>
        jQuery(function () {
            Xms.Web.Loading();
            function aLinkClick(e) {

                if (currentKeycode != 17 && window.parent && window.parent.addToTab) {
                    e.preventDefault();
                    var tabNav = $('#customTabNav', parent.document).children('.iframe-link-linkitem.active');
                    var textEl = tabNav.clone();
                    $(".glyphicon-remove", textEl).remove();
                    var label = textEl.text();
                    textEl = $(this).clone();
                    $("span", textEl).remove();
                    label = label + '-' + textEl.text();
                    var link = $(this).attr("href");
                    var id = $.md5(link);
                    Xms.Web.callParentMethod('addToTab', { id: id, label: label, link: link });
                    return false;
                } else {
                    //  currentKeycode = -99999;
                    //  var link = $(this).attr("href");
                    //  Xms.Web.OpenWindow(link);
                }

            }
            var currentKeycode = -99999;
            $("body").on("click.customizeLinkclick", 'a[href]a:not([href^="javascript:"])a:not([href^="#"])', function (e) {
                aLinkClick.call(this, e);
            });
        });
    </script>
    <style>
    body {
        padding: 0;
        margin: 0;
    }

    .table-responsive {
        max-height: 400px;
        overflow-y: auto;
    }

    .panel-default .panel-heading {
        background-color: white;
    }
</style>
</head>
<body>
<div class="" id="body">
    <div class="clearfix">
        <div class="col-md-12" id="main">
            <div class="" style="padding:5px;" id="renderBody">
                <!--main-->

                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <a data-toggle="collapse"
                               href="#collapseTwo">
                                <strong>配置关系</strong>
                            </a>
                        </h3>
                    </div>
                    <div id="collapseTwo" class="panel-collapse collapse in">
                        <div class="panel-body">
                            <form action="/xms/api/schema/relationship/update" data-jsonajax="true" data-formdata="false" method="post" id="editform" class="form-horizontal" role="form">
                                <input data-val="true" data-val-required="The RelationShipId field is required." id="relationshipid" name="relationshipid" data-name="relationshipid" type="hidden" />
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="referencedentitylocalizedname">主要实体</label>
                                    <div class="col-sm-10">
                                        <input class="form-control required" disabled="True" id="referencedentitylocalizedname" name="referencedentitylocalizedname" data-name="referencedentitylocalizedname" type="text" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="referencingentitylocalizedname">关联实体</label>
                                    <div class="col-sm-10">
                                        <input class="form-control required" disabled="True" id="referencingentitylocalizedname" name="referencingentitylocalizedname" data-name="referencingentitylocalizedname" type="text" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="name">名称</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" id="name" name="name" data-name="name" type="text" disabled />
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="cascadelinkmask">行为类型</label>
                                    <div class="col-sm-10">
                                        <select id="cascadelinkmask" name="cascadelinkmask" data-name="cascadelinkmask" class="form-control" >
                                            <option value="1">父</option>
                                            <option value="2">引用</option>
                                            <option value="3">引用，限制删除</option>
                                            <option value="4">可配置项的级联</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="cascadeassign">分派</label>
                                    <div class="col-sm-10">
                                        <select id="cascadeassign" name="cascadeassign" data-name="cascadeassign" class="form-control">
                                            <option value="1">全部级联</option>
                                            <option value="2">可用项的级联</option>
                                            <option value="3">用户负责项的级联</option>
                                            <option value="4">无级联</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="cascadeshare">共享</label>
                                    <div class="col-sm-10">
                                        <select id="cascadeshare" name="cascadeshare" data-name="cascadeshare" class="form-control">
                                            <option value="1">全部级联</option>
                                            <option value="2">可用项的级联</option>
                                            <option value="3">用户负责项的级联</option>
                                            <option value="4">无级联</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="cascadeunshare">取消共享</label>
                                    <div class="col-sm-10">
                                        <select id="cascadeunshare" name="cascadeunshare" data-name="cascadeunshare" class="form-control">
                                            <option value="1">全部级联</option>
                                            <option value="2">可用项的级联</option>
                                            <option value="3">用户负责项的级联</option>
                                            <option value="4">无级联</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="col-sm-2 control-label" for="cascadedelete">删除</label>
                                    <div class="col-sm-10">
                                        <select id="cascadedelete" name="cascadedelete" data-name="cascadedelete" class="form-control">
                                            <option value="1">全部级联</option>
                                            <option value="2">移除链接</option>
                                            <option value="3">限制</option>
                                            <option value="4">无级联</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12 text-center" id="form-buttons">
                                    <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-saved"></span> 保存</button>
                                    <button type="reset" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> 重置</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

            </div>
            <nav class="navbar navbar-default navbar-fixed-bottom hide" role="navigation" id="body-footer">
                <div class="container">
                    <div class="navbar-form navbar-right" id="body-footer-content">
                    </div>
                </div>
            </nav>
        </div>
    </div>
</div>

<script src="/content/js/jquery.form.js"></script>
<script src="/content/js/jquery-validate/jquery.validate.min.js"></script>
<script src="/content/js/jquery-validate/localization/messages_zh.min.js"></script>
<script src="/content/js/xms.fillform.js"></script>
<script>
    var model = $.urlParamObj(location.href);
    function loadData() {
        Xms.Web.GetJson('/api/schema/relationship/getbyid/' + model.id, null, function (res) {
            var data = res.Content;
            if(!data) return;
            $('#editform').fillForm(data);
            $('#cascadelinkmask').attr('data-value', data.cascadelinkmask);
            $('#cascadeassign').attr('data-value', data.cascadeassign);
            $('#cascadeshare').attr('data-value', data.cascadeshare);
            $('#cascadeunshare').attr('data-value', data.cascadeunshare);
            $('#cascadedelete').attr('data-value', data.cascadedelete);
            if(data.iscustomizable == false){
                $('#cascadelinkmask').attr('disabled', 'disabled');
                $('#cascadeassign').attr('disabled', 'disabled');
                $('#cascadeshare').attr('disabled', 'disabled');
                $('#cascadeunshare').attr('disabled', 'disabled');
                $('#cascadedelete').attr('disabled', 'disabled');
                $('#body-footer').remove();
            }
        }, null, false, 'GET', true);
    }
    $(function () {
        loadData();
        //表单验证
        Xms.Web.Form($("#editform"));

        Xms.Web.SelectedValue($('#cascadelinkmask'), $('#cascadelinkmask').attr('data-value'));
        Xms.Web.SelectedValue($('#cascadeassign'), $('#cascadeassign').attr('data-value'));
        Xms.Web.SelectedValue($('#cascadeshare'), $('#cascadeshare').attr('data-value'));
        Xms.Web.SelectedValue($('#cascadeunShare'), $('#cascadeunshare').attr('data-value'));
        Xms.Web.SelectedValue($('#cascadedelete'), $('#cascadedelete').attr('data-value'));
    });
</script>

</body>
</html>